<?
if($_REQUEST['act']=="Export"){
	require_once 'class/PHPExcel.php'; 
	require_once('class/PHPExcel/Writer/Excel2007.php');  	
	$objExcel = new PHPExcel();   
	$objExcel->setActiveSheetIndex(0);       
	$objActSheet = $objExcel->getActiveSheet();       	
	$objWriter = new PHPExcel_Writer_Excel5($objExcel);   
	$n=1; 
	$objActSheet->getColumnDimension('A')->setAutoSize(true); 
	$objActSheet->getColumnDimension('B')->setAutoSize(true);  
	$objActSheet->getColumnDimension('C')->setAutoSize(true);  
	$objActSheet->getColumnDimension('D')->setAutoSize(true);  
	$objActSheet->getColumnDimension('E')->setAutoSize(true);
	$objActSheet->getColumnDimension('F')->setAutoSize(true);  	
	$objActSheet->setCellValue('A'.$n, "分销商名称");    
	$objActSheet->setCellValue('B'.$n, "增加金额");  
	$objActSheet->setCellValue('C'.$n, "减少金额");
	$objActSheet->setCellValue('D'.$n, "操作后金额");
	$objActSheet->setCellValue('E'.$n, "操作时间");
	$objActSheet->setCellValue('F'.$n, "操作员");
	$objActSheet->getStyle('A'.$n)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
	foreach($list as $row){
		$n++;
		$objActSheet->setCellValue('A'.$n, $row['dname']);    
		$objActSheet->setCellValue('B'.$n, $row['add']);
		$objActSheet->setCellValue('C'.$n, $row['redu']);
		$objActSheet->setCellValue('D'.$n, $row['lmoney']/100);
		$objActSheet->setCellValue('E'.$n, $row['rectime']);    
		$objActSheet->setCellValue('F'.$n, $oper[$row['opid']]);
		//输出样式
		$objActSheet->getStyle('A'.$n)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT); 
	}
	$filename=date('Ymd').'分销商资金记录';
	$ua = $_SERVER['HTTP_USER_AGENT'];  
	if(preg_match('/MSIE/',$ua))$filename = str_replace('+','%20',urlencode($filename)); 
	$filename.=".xls";
	header("Content-Type: application/force-download");  
	header("Content-Type: application/octet-stream");  
	header("Content-Type: application/download");  
	header("Content-Disposition:inline;filename=$filename");  
	header("Content-Transfer-Encoding: binary");  
	header("Cache-Control: must-revalidate, post-check=0, pre-check=0");  
	header("Pragma: no-cache");  
	$objWriter->save('php://output');
	exit;
}
?>